home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / bash / bash_110 / mint / bash110s.zoo / bash-1.10 / general.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-14  |  1.9 KB  |  83 lines

  1. /* general.h -- defines that everybody likes to use. */
  2.  
  3. #if !defined (_GENERAL_)
  4. #define _GENERAL_
  5.  
  6. #if !defined (NULL)
  7. #define NULL 0x0
  8. #endif
  9.  
  10. #ifndef savestring
  11. #define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x))
  12. #endif
  13.  
  14. #ifndef whitespace
  15. #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
  16. #endif
  17.  
  18. #ifndef digit
  19. #define digit(c)  ((c) >= '0' && (c) <= '9')
  20. #endif
  21.  
  22. #ifndef isletter
  23. #define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
  24. #endif
  25.  
  26. #ifndef digit_value
  27. #define digit_value(c) ((c) - '0')
  28. #endif
  29.  
  30. #if !defined (__STDC__)
  31. char *index (), *rindex ();
  32. #endif
  33.  
  34. #ifndef member
  35. #define member(c, s) (int)((c) ? index ((s), (c)) : 0)
  36. #endif
  37.  
  38. /* Here is a generic structure for associating character strings
  39.    with integers.  It is used in the parser for shell tokenization. */
  40. typedef struct {
  41.   char *word;
  42.   int token;
  43. } STRING_INT_ALIST;
  44.  
  45. /* String comparisons that possibly save a function call each. */
  46. #define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
  47. #define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)
  48.  
  49. /* Function pointers can be declared as (Function *)foo. */
  50. #if !defined (__FUNCTION_DEF)
  51. #define __FUNCTION_DEF
  52. typedef int Function ();
  53. typedef void VFunction ();
  54. #endif /* _FUNCTION_DEF */
  55.  
  56. /* The output of `signal' is different on different systems.  Yechh. */
  57. #if !defined (VOID_SIGHANDLER)
  58. #  if defined (_POSIX_HANDLER) || (SunOS4) || defined (NeXT) || defined (Ultrix) || defined (USG)
  59. #    define VOID_SIGHANDLER
  60. #  endif
  61. #endif
  62.  
  63. #if defined (VOID_SIGHANDLER)
  64. #define sighandler void
  65. #else
  66. #define sighandler int
  67. #endif
  68.  
  69. typedef sighandler SigHandler ();
  70.  
  71. #define NOW    ((time_t) time ((time_t *) 0))
  72.  
  73. /* Some defines for calling file status functions. */
  74. #define FS_EXISTS      0x1
  75. #define FS_EXECABLE      0x2
  76. #define FS_EXEC_PREFERRED 0x4
  77. #define FS_EXEC_ONLY      0x8
  78.  
  79. extern char *xmalloc (), *malloc (), *xrealloc (), *realloc ();
  80. extern char *itos ();
  81.  
  82. #endif    /* _GENERAL_ */
  83.